<template>
  <cart-list/>
  <cart-option/>
  <simi-recommend :data="likeGood"
                  class="container"
                  title="猜你喜欢"/>
</template>

<script lang="ts"
        setup>
import {getRecommendGoods} from '@/api/good'
import CartList from '@/components/library/CartList.vue'
import CartOption from '@/components/library/CartOption.vue'
import SimiRecommend from '@/components/library/SimiRecommend.vue'
import {useCommonStore} from '@/stores/common'
import type {Good} from '@/types/good'
import {provide, ref} from 'vue'

let store = useCommonStore()
store.pathList = [store.pathList[0], {name: '购物车', path: ''}]

let likeGood = ref<Good[]>([])

provide('simiIndex', ref<number>(0))

let requestAll = () => {
  Promise.all([
    getRecommendGoods()
  ]).then(([likeGoodRes]) => {
    initLikeGood(likeGoodRes)
  })
}

function initLikeGood(res: any) {
  likeGood.value = <Good[]>res.result
}

requestAll()
</script>

<style lang="less"
       scoped>
.container {
  margin-bottom: 20px;
}
</style>